From 9e824c3439a2ae410b16d894b210ae9a07fd447f Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 17 May 2017 14:14:41 +0200 Subject: [PATCH] Only compile user-modifiable projects incrementally. --- src/cargo/ops/cargo_rustc/context.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index e17a0823b..33f9947e6 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -904,7 +904,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } pub fn incremental_args(&self, unit: &Unit) -> CargoResult> { - if self.incremental_enabled { + // Only enable incremental compilation for sources the user can modify. + // For things that change infrequently, non-incremental builds yield + // better performance. + // (see also https://github.com/rust-lang/cargo/issues/3972) + if self.incremental_enabled && unit.pkg.package_id().source_id().is_path() { Ok(vec![format!("-Zincremental={}", self.layout(unit.kind).incremental().display())]) } else { Ok(vec![]) -- 2.30.2